<#macro paging result>
<div style="text-align: center">
    <div id="laypage-main">
    </div>
    <script>
        layui.use('laypage', function(){
            var laypage = layui.laypage;

            //执行一个laypage实例
            laypage.render({
                elem: 'laypage-main'
                ,count: ${result.total}
                ,limit: ${result.size}
                ,curr: ${result.current}
                ,jump: function(obj, first){
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数

                    //首次不执行
                    if(!first){
                        location.href="?pn="+obj.curr;
                    }
                }
            });
        });
    </script>
</div>
</#macro>

<#macro postlist postvo>
    <li>
        <a href="/user/${postvo.authorId}" class="fly-avatar">
            <img src="${postvo.authorUrl}" alt="${postvo.authorName}">
        </a>
        <h2>
            <a class="layui-badge">${postvo.categoryName}</a>
            <a href="/post/detail/${postvo.id}">${postvo.title}</a>
        </h2>
        <div class="fly-list-info">
            <a href="/user/${postvo.authorId}" link>
                <cite>${postvo.authorName}</cite>
            </a>
            <span>${timeAgo(postvo.created)}</span>
            <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> ${postvo.commentCount}
              </span>
        </div>
        <div class="fly-list-badge">
            <!--
            <span class="layui-badge layui-bg-black">置顶</span>
            <span class="layui-badge layui-bg-red">精帖</span>
            -->
            <#if postvo.level gt 0 ><span class="layui-badge layui-bg-black">置顶</span></#if>
            <#if postvo.recommend> <span class="layui-badge layui-bg-red">精帖</span></#if>
        </div>
    </li>
</#macro>
